// constructing priority queues
// #include <iostream>       // std::cout
// #include <queue>          // std::priority_queue
// #include <vector>         // std::vector
// #include <functional>     // std::greater

using namespace std;

// class mycomparison
// {
//   bool reverse;
// public:
//   mycomparison(const bool& revparam=false)
//     {reverse=revparam;}
//   bool operator() (const int& lhs, const int&rhs) const
//   {
//     if (reverse) return (lhs>rhs);
//     else return (lhs<rhs);
//   }
// };

// public void print(priority_queue q){
//     for(auto e : q){
//         cout<<e<<" ";
//     }
//     cout<<endl;
// }

// int main ()
// {
//   int myints[]= {10,60,50,20};

//   std::priority_queue<int> first;
//   std::priority_queue<int> second (myints,myints+4);
//   std::priority_queue<int, std::vector<int>, std::greater<int> >
//                             third (myints,myints+4);
//   // using mycomparison:
//   typedef std::priority_queue<int,std::vector<int>,mycomparison> mypq_type;

//   mypq_type fourth;                       // less-than comparison
//   mypq_type fifth (mycomparison(true));   // greater-than comparison

  

//   return 0;
// }

#include <complex>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
 
int main()
{
    std::priority_queue<int> pq1;
    pq1.push(5);
    std::cout << "pq1.size() = " << pq1.size() << '\n';
 
    std::priority_queue<int> pq2 {pq1};
    std::cout << "pq2.size() = " << pq2.size() << '\n';
 
    std::vector<int> vec {3, 1, 4, 1, 5};
    std::priority_queue<int> pq3 {std::less<int>(), vec};
    std::cout << "pq3.size() = " << pq3.size() << '\n';
    cout<<pq3.top()<<endl;
 
    for (std::cout << "pq3 : "; !pq3.empty(); pq3.pop())
    {
        std::cout << pq3.top() << ' ';
    }
    std::cout << '\n';
 
 
    // Demo With Custom Comparator:
 
    using my_value_t = std::complex<double>;
    using my_container_t = std::vector<my_value_t>;
 
    auto my_comp = [](const my_value_t& z1, const my_value_t& z2) {
        return z2.real() < z1.real();
    };
 
    std::priority_queue<my_value_t,
                        my_container_t,
                        decltype(my_comp)> pq4 {my_comp};
 
    using namespace std::complex_literals;
    pq4.push(5.0 + 1i);
    pq4.push(3.0 + 2i);
    pq4.push(7.0 + 3i);
 
    for (; !pq4.empty(); pq4.pop())
    {
        const auto& z = pq4.top();
        std::cout << "pq4.top() = " << z << '\n';
    }
}